package com.gao.pubsub.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisUtil {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 消息发布
     * @param channel 频道
     * @param msg 消息内容
     */
    public void publish(String channel, Object msg) {
        stringRedisTemplate.convertAndSend(channel, msg);
    }
}
